﻿namespace Raven
{
    public enum EntityType
    {
        Wall = 0,
        Bot = 1,
        Health = 4,
        SpawnPoint = 5,
        RailGunWeaponGiver = 6,
        RocketLauncherWeaponGiver = 7,
        ShotgunWeaponGiver = 8,
        Grave = 10,
        Bolt = 11,
        Slug = 12,
        Rocket = 13,
        Pellet = 14,
        SoundNotify = 15,
    }

    public abstract class BaseGameEntity
    {
        private static int _nextValidID;

        public BaseGameEntity(EntityType type)
        {
            _type = type;
            SetID(_nextValidID);
        }

        //every entity has a type associated with it (health, troll, ammo etc)
        private EntityType _type;

        private int _ID;

        private bool _tag;

        public int ID()
        {
            return _ID;
        }

        public bool IsTagged()
        {
            return _tag;
        }

        public void Tag()
        {
            _tag = true;
        }

        public void UnTag()
        {
            _tag = false;
        }

        public Fix BRadius()
        {
            return m_dBoundingRadius;
        }

        public void SetBRadius(Fix r)
        {
            m_dBoundingRadius = r;
        }

        public EntityType GetEntityType()
        {
            return _type;
        }

        public static void ResetNextValidID()
        {
            _nextValidID = 0;
        }

        protected Vector2 _position;

        protected Fix m_dBoundingRadius;

        public Vector2 Pos()
        {
            return _position;
        }

        public void SetPos(Vector2 new_pos)
        {
            _position = new_pos;
        }

        private void SetID(int val)
        {
            //make sure the val is equal to or greater than the next available ID
            Utility.Assert(val >= _nextValidID, "<BaseGameEntity::SetID>: invalid ID");

            _ID = val;

            _nextValidID = _ID + 1;
        }

        public abstract void Destroy();

        public virtual bool HandleMessage(Telegram msg)
        {
            return false;
        }
    }
}